package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.LogBean;
import com.project.mapper.ILogMapper;
import com.project.service.ILogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

/**
 * 日志实现类
 */
@Service
@Transactional
public class LogServiceImpl implements ILogService {
    @Autowired
    private ILogMapper logMapper;
    @Override
    public IPage<LogBean> cutByItem(Integer pageNO, LocalDate startDate, LocalDate endDate) {
        QueryWrapper<LogBean> qw=new QueryWrapper<>();
        if (startDate !=null){
            qw.ge("l_date",startDate);
        }

        if (endDate !=null){
            qw.le("l_date",endDate);
        }
        return logMapper.selectPage(new Page<>(pageNO,3),qw);
    }

    @Override
    public void addLog(LogBean log) {
        logMapper.insert(log);
    }
}
